<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.14.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>DM-CtrlH7-BF-DevProgram: C:/Users/ASUS/Desktop/dm-ctrlH7-balance-9025test/bsp/usart/bsp_usart.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="50x5.png"/></td>
  <td id="projectalign">
   <div id="projectname">DM-CtrlH7-BF-DevProgram<span id="projectnumber">&#160;beta 0.1</span>
   </div>
   <div id="projectbrief">C.ONE Studio Damiao Development Board Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.14.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search',true);
  $(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(function(){initNavTree('bsp__usart_8c.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="headertitle"><div class="title">bsp_usart.c File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>串口bsp层的实现  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;bsp_usart.h&quot;</code><br />
<code>#include &quot;bsp_log.h&quot;</code><br />
<code>#include &quot;stdlib.h&quot;</code><br />
<code>#include &quot;memory.h&quot;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-func-members" class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ac45bba3591501c066f505a46dbae7e2b" id="r_ac45bba3591501c066f505a46dbae7e2b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ac45bba3591501c066f505a46dbae7e2b">USARTServiceInit</a> (<a class="el" href="struct_u_s_a_r_t_instance.html">USARTInstance</a> *_instance)</td></tr>
<tr class="memdesc:ac45bba3591501c066f505a46dbae7e2b"><td class="mdescLeft">&#160;</td><td class="mdescRight">启动串口服务,会在每个实例注册之后自动启用接收,当前实现为DMA接收,后续可能添加IT和BLOCKING接收  <br /></td></tr>
<tr class="memitem:a4296c218240b51944ecb698eed2625ef" id="r_a4296c218240b51944ecb698eed2625ef"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_u_s_a_r_t_instance.html">USARTInstance</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a4296c218240b51944ecb698eed2625ef">USARTRegister</a> (<a class="el" href="struct_u_s_a_r_t___init___config__s.html">USART_Init_Config_s</a> *init_config)</td></tr>
<tr class="memdesc:a4296c218240b51944ecb698eed2625ef"><td class="mdescLeft">&#160;</td><td class="mdescRight">注册一个串口实例,返回一个串口实例指针  <br /></td></tr>
<tr class="memitem:a12acc10fbb458df894b53534ae66c25d" id="r_a12acc10fbb458df894b53534ae66c25d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a12acc10fbb458df894b53534ae66c25d">USARTSend</a> (<a class="el" href="struct_u_s_a_r_t_instance.html">USARTInstance</a> *_instance, uint8_t *send_buf, uint16_t send_size, USART_TRANSFER_MODE mode)</td></tr>
<tr class="memdesc:a12acc10fbb458df894b53534ae66c25d"><td class="mdescLeft">&#160;</td><td class="mdescRight">通过调用该函数可以发送一帧数据,需要传入一个usart实例,发送buff以及这一帧的长度  <br /></td></tr>
<tr class="memitem:a4a4a562d3a505abe103d09f65ef860e4" id="r_a4a4a562d3a505abe103d09f65ef860e4"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a4a4a562d3a505abe103d09f65ef860e4">USARTIsReady</a> (<a class="el" href="struct_u_s_a_r_t_instance.html">USARTInstance</a> *_instance)</td></tr>
<tr class="memdesc:a4a4a562d3a505abe103d09f65ef860e4"><td class="mdescLeft">&#160;</td><td class="mdescRight">判断串口是否准备好,用于连续或异步的IT/DMA发送  <br /></td></tr>
<tr class="memitem:ga925534fb8bf7ca464fd05c982fe4bfa0" id="r_ga925534fb8bf7ca464fd05c982fe4bfa0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___u_a_r_t___exported___functions___group2.html#ga925534fb8bf7ca464fd05c982fe4bfa0">HAL_UARTEx_RxEventCallback</a> (<a class="el" href="group___u_a_r_t___exported___types.html#ga5de4a49eb132735325e706f406c69d6e">UART_HandleTypeDef</a> *huart, uint16_t Size)</td></tr>
<tr class="memdesc:ga925534fb8bf7ca464fd05c982fe4bfa0"><td class="mdescLeft">&#160;</td><td class="mdescRight">每次dma/idle中断发生时，都会调用此函数.对于每个uart实例会调用对应的回调进行进一步的处理 例如:视觉协议解析/遥控器解析/裁判系统解析  <br /></td></tr>
<tr class="memitem:ga0e0456ea96d55db31de947fb3e954f18" id="r_ga0e0456ea96d55db31de947fb3e954f18"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___u_a_r_t___exported___functions___group2.html#ga0e0456ea96d55db31de947fb3e954f18">HAL_UART_ErrorCallback</a> (<a class="el" href="group___u_a_r_t___exported___types.html#ga5de4a49eb132735325e706f406c69d6e">UART_HandleTypeDef</a> *huart)</td></tr>
<tr class="memdesc:ga0e0456ea96d55db31de947fb3e954f18"><td class="mdescLeft">&#160;</td><td class="mdescRight">当串口发送/接收出现错误时,会调用此函数,此时这个函数要做的就是重新启动接收  <br /></td></tr>
</table>
<a name="details" id="details"></a><h2 id="header-details" class="groupheader">Detailed Description</h2>
<div class="textblock"><p>串口bsp层的实现 </p>
<dl class="section author"><dt>Author</dt><dd>neozng </dd></dl>
<dl class="section version"><dt>Version</dt><dd>beta </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2022-11-01</dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright (c) 2022 </dd></dl>
</div><a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Function Documentation</h2>
<a id="a4a4a562d3a505abe103d09f65ef860e4" name="a4a4a562d3a505abe103d09f65ef860e4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4a4a562d3a505abe103d09f65ef860e4">&#9670;&#160;</a></span>USARTIsReady()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t USARTIsReady </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_u_s_a_r_t_instance.html">USARTInstance</a> *</td>          <td class="paramname"><span class="paramname"><em>_instance</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>判断串口是否准备好,用于连续或异步的IT/DMA发送 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">_instance</td><td>要判断的串口实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>uint8_t ready 1, busy 0 </dd></dl>

</div>
</div>
<a id="a4296c218240b51944ecb698eed2625ef" name="a4296c218240b51944ecb698eed2625ef"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4296c218240b51944ecb698eed2625ef">&#9670;&#160;</a></span>USARTRegister()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct_u_s_a_r_t_instance.html">USARTInstance</a> * USARTRegister </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_u_s_a_r_t___init___config__s.html">USART_Init_Config_s</a> *</td>          <td class="paramname"><span class="paramname"><em>init_config</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>注册一个串口实例,返回一个串口实例指针 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">init_config</td><td>传入串口初始化结构体 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a12acc10fbb458df894b53534ae66c25d" name="a12acc10fbb458df894b53534ae66c25d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a12acc10fbb458df894b53534ae66c25d">&#9670;&#160;</a></span>USARTSend()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void USARTSend </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_u_s_a_r_t_instance.html">USARTInstance</a> *</td>          <td class="paramname"><span class="paramname"><em>_instance</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *</td>          <td class="paramname"><span class="paramname"><em>send_buf</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t</td>          <td class="paramname"><span class="paramname"><em>send_size</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">USART_TRANSFER_MODE</td>          <td class="paramname"><span class="paramname"><em>mode</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>通过调用该函数可以发送一帧数据,需要传入一个usart实例,发送buff以及这一帧的长度 </p>
<dl class="section note"><dt>Note</dt><dd>在短时间内连续调用此接口,若采用IT/DMA会导致上一次的发送未完成而新的发送取消. </dd>
<dd>
若希望连续使用DMA/IT进行发送,请配合USARTIsReady()使用,或自行为你的module实现一个发送队列和任务. </dd></dl>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000006">Todo</a></b></dt><dd>是否考虑为USARTInstance增加发送队列以进行连续发送?</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">_instance</td><td>串口实例 </td></tr>
    <tr><td class="paramname">send_buf</td><td>待发送数据的buffer </td></tr>
    <tr><td class="paramname">send_size</td><td>how many bytes to send </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ac45bba3591501c066f505a46dbae7e2b" name="ac45bba3591501c066f505a46dbae7e2b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac45bba3591501c066f505a46dbae7e2b">&#9670;&#160;</a></span>USARTServiceInit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void USARTServiceInit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_u_s_a_r_t_instance.html">USARTInstance</a> *</td>          <td class="paramname"><span class="paramname"><em>_instance</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>启动串口服务,会在每个实例注册之后自动启用接收,当前实现为DMA接收,后续可能添加IT和BLOCKING接收 </p>
<p>启动串口服务,需要传入一个usart实例.一般用于lost callback的情况(使用串口的模块daemon)</p>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000005">Todo</a></b></dt><dd>串口服务会在每个实例注册之后自动启用接收,当前实现为DMA接收,后续可能添加IT和BLOCKING接收 可能还要将此函数修改为extern,使得module可以控制串口的启停</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">_instance</td><td>instance owned by module,模块拥有的串口实例 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="page-nav" class="page-nav-panel">
<div id="page-nav-resize-handle"></div>
<div id="page-nav-tree">
<div id="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a href="dir_3c5459f7c179b79c90e2565474bb2856.html">bsp</a></li><li class="navelem"><a href="dir_8f31272b2552570da9d5b13ae61f54f3.html">usart</a></li><li class="navelem"><a href="bsp__usart_8c.html">bsp_usart.c</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
  </ul>
</div>
</body>
</html>
